package edu.gatech.cs4400.spring2014.A8.control;

import java.util.HashMap;

/**
 * Singleton class for holding information about the currently
 * logged in account.
 * 
 * @author Stephen
 */
public abstract class Session {
	public static enum AccountType{PATIENT, DOCTOR, AA};
	private static HashMap<String, AccountType> str2accountType;
	
	private static String username = null;
	private static AccountType accountType = null;
	
	/**
	 * Set the account information for the currently logged in account
	 * This information will control application flow and will be used
	 * in queries.
	 * 
	 * @param username 
	 * @param accountType
	 */
	public static void setActiveAccount(String username, String accountType) {
		if (str2accountType == null) {
			str2accountType = new HashMap<String, AccountType>();
			str2accountType.put("patient", AccountType.PATIENT);
			str2accountType.put("doctor", AccountType.DOCTOR);
			str2accountType.put("administrative assis", AccountType.AA);
		}
		if (!str2accountType.containsKey(accountType)) {
			System.out.printf("Unrecognized account type: %s\n", accountType);
		}
		
		Session.username = username;
		Session.accountType = str2accountType.get(accountType);
		
		
	}
	
	/**
	 * Get the last logged in username
	 * @return 
	 */
	public static String getUsername() {
		return username;
	}
	
	/**
	 * Get the last logged in account type
	 * @return
	 */
	public static AccountType getAccountType() {
		return accountType;
	}
}
